<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:easy="http://easyfaces.com.br/easyfaces"
	xml:lang="en" lang="en"
	>

	<ui:composition template="/WEB-INF/templates/layout_sedna_express.xhtml">
			
			<ui:define name="header2">
				<h:form>
					<h:panelGrid columns="2">
						<h:inputText value="#{telaPesquisa.filtro}" styleClass="campoPesquisa" />
						<h:commandButton value="Buscar" action="#{telaPesquisa.pesquisar}" styleClass="botaoPesquisa"/>
					</h:panelGrid>
				</h:form>
			</ui:define>
			
			<ui:define name="conteudo_center">
				<h:form>
					<div id="gridProdutos" class="gridProdutos">
					
						<rich:dataGrid value="#{telaPesquisa.produtos}" var="produto" columns="1" elements="10" width="100%">
							
							<h:panelGrid width="100%">
							
								<h:panelGrid columns="1" width="100%" columnClasses="td_branco">
									
									<h:panelGrid columns="6" columnClasses="td_imagem, td_descricao, td_fabricante, td_empresa, td_valor, td_data_ultima_pesquisa" width="100%">
									
										<a4j:commandLink   ajaxSingle="true" id="addItemLink" oncomplete="#{rich:component('editPanel')}.show()" >
											<h:graphicImage value="imagens/carrinho_add.png" style="border: 0;"/>
											<f:setPropertyActionListener  target="#{telaPesquisa.novoItem}"  value="#{produto}"/>
										</a4j:commandLink>
									
										<h:outputText value="#{produto.nome}"/>
										<h:outputText value="#{produto.fabricante.nome}"/>
										<h:commandLink value="#{produto.nomeEmpresa}"/>
										<h:panelGrid columns="2">
											R$<easy:outputCurrency value="#{produto.valor}" id="valorProduto" decimalSeparator="," groupSeparator="." />
										</h:panelGrid>
										
										
										<easy:outputCalendar value="#{produto.dataUltimaPesquisa}" />
										
										
									</h:panelGrid>
									
								</h:panelGrid>
							</h:panelGrid>
							
							<f:facet name="footer">
	                    		<rich:datascroller renderIfSinglePage="false" maxPages="10" />
	                		</f:facet>
	                		
						</rich:dataGrid>
					
					</div>					
				</h:form>
				
				<!-- FORMULARIO DO PAINEL MODAL -->
				<rich:modalPanel id="editPanel" autosized="true" width="500">
					
					<f:facet name="header">
						<h:outputText value="Informe a quantidade do item selecionado."/>
					</f:facet>
					<f:facet name="controls">
		            	<h:panelGroup>
			                <h:graphicImage value="imagens/close.png" id="hidelink" styleClass="hidelink" />
			                <rich:componentControl for="editPanel" attachTo="hidelink" operation="hide" event="onclick" />
		            	</h:panelGroup>
		        	</f:facet>
		        	
					<h:form>
			            <rich:messages style="color:red;" />
			            <h:panelGrid columns="1">
			                <a4j:outputPanel ajaxRendered="true">
			                    <h:panelGrid columns="2">
			                        <h:outputText value="Quantidade" />
			                        <easy:inputCurrency value="#{telaPesquisa.itemSelecionado.quantidade}" />
			                    </h:panelGrid>
			                    <!--  <rich:message showSummary="true" showDetail="false" for="price" />-->
			                    <h:messages style="color:red"/>
			                </a4j:outputPanel>
			                <a4j:commandButton value="Salvar"
			                    									 action="#{telaPesquisa.salvarItemSelecionado}"
			                    									 reRender="carrinhoCotacao"
			                   										 oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />
			            </h:panelGrid>
			        </h:form>
				</rich:modalPanel>
				
			</ui:define>			

			<ui:define name="menu_left">
				<div id="carrinhoCotacao">
					<h:form>
						<rich:panel id="carrinhoCotacao" rendered="true">
							<h:commandLink value="Cotação" action="cotacao">
								<f:setPropertyActionListener  target="#{telaCotacaoEdicao.cotacao}"  value="#{telaPesquisa.cotacao}"/>
							</h:commandLink><br/>
							<h:outputText value="Quant. Itens: " /> <h:outputText value="#{telaPesquisa.cotacao.quantidadeItens}" /> <br />
							<h:outputText value="Total R$: " /><easy:outputCurrency value="#{telaPesquisa.cotacao.valorTotal}" />
						</rich:panel>
					</h:form>
				</div>
			</ui:define>

	</ui:composition>	
</html>
